package com.ruoyi.game.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.game.utils.WxPayUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.game.domain.GamePacketRecord;
import com.ruoyi.game.service.IGamePacketRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 红包记录Controller
 * 
 * @author ruoyi
 * @date 2024-03-17
 */
@RestController
@RequestMapping("/game/packet_record")
public class GamePacketRecordController extends BaseController
{
    @Autowired
    private IGamePacketRecordService gamePacketRecordService;



    /**
     * 查询红包记录列表
     */
    @PreAuthorize("@ss.hasPermi('game:packet_record:list')")
    @GetMapping("/list")
    public TableDataInfo list(GamePacketRecord gamePacketRecord)
    {
        startPage();
        List<GamePacketRecord> list = gamePacketRecordService.selectGamePacketRecordList(gamePacketRecord);
        return getDataTable(list);
    }

    /**
     * 导出红包记录列表
     */
    @PreAuthorize("@ss.hasPermi('game:packet_record:export')")
    @Log(title = "红包记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GamePacketRecord gamePacketRecord)
    {
        List<GamePacketRecord> list = gamePacketRecordService.selectGamePacketRecordList(gamePacketRecord);
        ExcelUtil<GamePacketRecord> util = new ExcelUtil<GamePacketRecord>(GamePacketRecord.class);
        util.exportExcel(response, list, "红包记录数据");
    }

    /**
     * 获取红包记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('game:packet_record:query')")
    @GetMapping(value = "/{packetId}")
    public AjaxResult getInfo(@PathVariable("packetId") Long packetId)
    {
        return success(gamePacketRecordService.selectGamePacketRecordByPacketId(packetId));
    }

    /**
     * 新增红包记录
     */
    @PreAuthorize("@ss.hasPermi('game:packet_record:add')")
    @Log(title = "红包记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GamePacketRecord gamePacketRecord)
    {
        return toAjax(gamePacketRecordService.insertGamePacketRecord(gamePacketRecord));
    }

    /**
     * 修改红包记录
     */
    @PreAuthorize("@ss.hasPermi('game:packet_record:edit')")
    @Log(title = "红包记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GamePacketRecord gamePacketRecord)
    {

        return toAjax(gamePacketRecordService.updateGamePacketRecord(gamePacketRecord));
    }

    /**
     * 删除红包记录
     */
    @PreAuthorize("@ss.hasPermi('game:packet_record:remove')")
    @Log(title = "红包记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{packetIds}")
    public AjaxResult remove(@PathVariable Long[] packetIds)
    {
        return toAjax(gamePacketRecordService.deleteGamePacketRecordByPacketIds(packetIds));
    }
}
